package com.ruoyi.access.util;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class FileUtil {

    /**
     * 读取文件为字符串
     */
    public static String readFile(String path) throws IOException {
        return new String(Files.readAllBytes(Paths.get(path)));
    }

    /**
     * 写字符串到文件
     */
    public static void writeFile(String path, String content) throws IOException {
        Files.write(Paths.get(path), content.getBytes());
    }

    /**
     * 检查文件是否存在
     */
    public static boolean exists(String path) {
        return Files.exists(Paths.get(path));
    }
}
